<template>
    <div class="wrapper">
        <div class="left-page">
            <Search/>
            <div class="cell-row">
                <DBRow :list="dbList" />
                <YJRow/>
            </div>
            <div class="cell-row">
                <BSRow/>
                <JJRow/>
            </div>
        </div>
        <div class="right-page">
            <MyStat/>
            <TakeNumber/>
            <Chests :list="dbList" />
        </div>
        <RegisterDialog title="预审登记" v-on:onSubmit="onSubmit" />
    </div>
</template>
<script>
import Pubsub from "../../utils/pubsub";
import {
    tySmartCabinetInfo,
    tyAddHandle,
    pushWebSocket
} from "../../config/api";

import Search from "../../components/common/search.vue"; //办件查询
import LabelRow from "../../components/common/labelRow.vue";

import DBRow from "../../components/unifyAcceptWorkbench/dbRow.vue"; //待办事项
import YJRow from "../../components/unifyAcceptWorkbench/yjRow.vue"; //预警提醒
import BSRow from "../../components/unifyAcceptWorkbench/bsRow.vue"; //办事指南
import JJRow from "../../components/unifyAcceptWorkbench/jjRow.vue"; //我的寄件
import MyStat from "../../components/unifyAcceptWorkbench/myStat.vue"; //我的统计
import TakeNumber from "../../components/unifyAcceptWorkbench/takeNumber.vue"; //取号情况
import Chests from "../../components/unifyAcceptWorkbench/chests.vue"; //智能柜使用情况
import RegisterDialog from "../../components/common/registerDialog.vue"; //预审登记弹窗

export default {
    components: {
        LabelRow,
        Search,
        DBRow,
        YJRow,
        BSRow,
        JJRow,
        MyStat,
        TakeNumber,
        RegisterDialog,
        Chests
    },
    data() {
        return {
            searchList: [],
            keywords: "",
            dbList: []
        };
    },
    mounted() {
        // 待办事项列表
        // setTimeout(()=>{
        //     pushWebSocket({type:"TAKE_NUM",takeNumId:"1"})
        // },3000)
        this.getSmartCabinetInfo({});
        //监听叫号
        this.pubsub_token1 = Pubsub.subscribe("CALLING", (t, args) => {
            let {
                handleInfo,
                handleInfoName,
                handlePersonName,
                handlePersonCardNum,
                createTime,
                rankNum,
                telNo,
                cardStartTime,
                cardEndTime
            } = args;
            let obj = {
                rankNum,
                takeTime: createTime,
                handleInfo,
                telNo,
                handleInfoName,
                handlePersonName,
                handlePersonCardNum,
                handlePersonStartTime: cardStartTime,
                handlePersonEndTime: cardEndTime,
                id: args.id
            };
            Pubsub.publish("showRegisterDialog", {
                type: "tysl",
                handleType: "workbench",
                ...obj
            });
        });
        //监听待办和智能柜
        this.pubsub_token2 = Pubsub.subscribe("PRETRIAL_TODO", (t, args) => {
            this.getSmartCabinetInfo({});
        });
      
    },
    destroyed() {
        this.pubsub_token1 && Pubsub.unsubscribe(this.pubsub_token1);
        this.pubsub_token2 && Pubsub.unsubscribe(this.pubsub_token2);
    },
    methods: {
       
        //新增确定按钮回调函数
        onSubmit(request) {
            tyAddHandle(request).then(() => {
                Pubsub.publish("hideRegisterDialog");
                this.$message({
                    message: "操作成功",
                    type: "success"
                });
            });
        },
        getSmartCabinetInfo(r = {}) {
            tySmartCabinetInfo(r).then((result = {}) => {
                let data = result.data || [];
                this.dbList = data;
            });
        }
    }
};
</script>

<style lang="scss" scoped>
.wrapper {
    display: flex;
    align-items: center;
}
.search-row {
    display: flex;
    margin-bottom: 30px;
}
.left-page {
    flex: 2;
    padding: 30px 30px 20px 20px;

    .cell-row {
        display: flex;
        margin-bottom: 20px;
        &:last-child {
            margin-bottom: 0;
        }
    }
}
.right-page {
    flex: 1;
    background: #fff;
    padding: 25px 30px 0 30px;
}
</style>
